<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/1/10
 * Time: 10:56
 */

namespace common\business\kd;

use Yii;
use yii\db\ActiveRecord;

///**
// * @property string $fid
// * @property string $name
// * @property string $number
// * @property integer $gender
// * @property string $birthday
// * @property string $email
// * @property string $mobile
// * @property string $id_card_num
// * @property string $native_place
// * @property string $blood_type
// * @property string $wed_status
// * @property string $nationality
// * @property string $folk
// * @property string $hklx
// * @property string $weixin
// * @property string $position_name
// * @property string $position_number
// * @property string $labor_relation_state
// * @property string $department_name
// * @property string $department_number
// * @property string $department_display_name
//*/
class KdPerson extends ActiveRecord
{
    /**
     * @var string
     */
    public $fid;
    /**
     * @var string
     */
    public $name;
    /**
     * @var string
     */
    public $number;
    /**
     * @var integer
     */
    public $gender;
    /**
     * @var string
     */
    public $birthday;
    /**
     * @var string
     */
    public $email;
    /**
     * @var string
     */
    public $mobile;
    /**
     * @var string
     */
    public $id_card_num;
    /**
     * @var string
     */
    public $native_place;
    /**
     * @var string
     */
    public $blood_type;
    /**
     * @var string
     */
    public $wed_status;
    /**
     * @var string
     */
    public $nationality;
    /**
     * @var string
     */
    public $folk;
    /**
     * @var string
     */
    public $hklx;
    /**
     * @var string
     */
    public $weixin;
    /**
     * @var string
     */
    public $position_name;
    /**
     * @var string
     */
    public $position_number;
    /**
     * @var string
     */
    public $labor_relation_state;
    /**
     * @var string
     */
    public $department_name;
    /**
     * @var string
     */
    public $department_number;
    /**
     * @var string
     */
    public $department_display_name;

//    /**
//     * @inheritdoc
//     */
//    public static function tableName()
//    {
////        return 'T_BD_PERSON';
//    }

    /**
     * @return \yii\db\Connection the database connection used by this AR class.
     */
    public static function getDb()
    {
        return Yii::$app->get('db_hr');
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['gender'], 'integer'],
            [['fid', 'name', 'number', 'birthday', 'email', 'mobile', 'id_card_num', 'native_place', 'blood_type', 'wed_status', 'nationality', 'folk', 'hklx', 'weixin',
                'position_name', 'position_number', 'labor_relation_state', 'department_name', 'department_number', 'department_display_name'], 'safe'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'fid' => Yii::t('app', 'ID'),
            'name' => Yii::t('app', 'Name'),
            'number' => Yii::t('app', 'Number'),
            'gender' => Yii::t('app', 'Gender'),
            'birthday' => Yii::t('app', 'Birthday'),
            'email' => Yii::t('app', 'Email'),
            'mobile' => Yii::t('app', 'Mobile'),
            'id_card_num' => Yii::t('app', 'Id Card Num'),
            'native_place' => Yii::t('app', 'Native Place'),
            'blood_type' => Yii::t('app', 'Blood Type'),
            'wed_status' => Yii::t('app', 'Wed Status'),
            'nationality' => Yii::t('app', 'Nationality'),
            'folk' => Yii::t('app', 'Folk'),
            'hklx' => Yii::t('app', 'Hklx'),
            'weixin' => Yii::t('app', 'Weixin'),
            'position_name' => Yii::t('app', 'Position Name'),
            'position_number' => Yii::t('app', 'Position Number'),
            'labor_relation_state' => Yii::t('app', 'Labor Relation State'),
            'department_name' => Yii::t('app', 'Department Name'),
            'department_number' => Yii::t('app', 'Department Number'),
            'department_display_name' => Yii::t('app', 'Department Display Name'),
        ];
    }

    public function getPrintName(){
        return sprintf('姓名: %s 工号: %s', $this->name, $this->number);
    }
}